/**
 * 
 */
package niuke.wangyi;

import java.util.Scanner;
import java.util.Stack;

/**
 * 括号嵌套是否正确 用栈
 * 
 * @author zhongfang
 *
 */
public class test1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String string = scanner.nextLine();
		scanner.close();
		Stack<Character> stack = new Stack<>();
		boolean valid = true;
		for (int i = 0; i < string.length(); i++) {
			char ch = string.charAt(i);
			if (ch == '(' || ch == '[' || ch == '{') {
				stack.push(ch);
			} else if (ch == ')') {
				if (stack.isEmpty() || stack.pop() != '(') {
					valid = false;
					break;
				}
			} else if (ch == ']') {
				if (stack.isEmpty() || stack.pop() != '[') {
					valid = false;
					break;
				}
			} else if (ch == '}') {
				if (stack.isEmpty() || stack.pop() != '{') {
					valid = false;
					break;
				}
			}
		}
		if (valid) {
			System.out.println("true");
		} else {
			System.out.println("false");
		}
	}

}
